﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Objects;
using Northwind.NET.Model;
using Northwind.NET.Settings;

namespace Northwind.NET.EDM.FE.WinForms.Controls
{
    public class BaseUserControl: UserControl
    {
        public class ControlLoadedEventArgs : EventArgs
        {
            public string ControlName { get; set; }
            public string ControlTitle { get; set; }
        }
        public EventHandler<ControlLoadedEventArgs> ControlLoaded;  

        public virtual string FormCaption { get { return "?"; } }
        public virtual dynamic GetEntitySet(ObjectContext context) {return null;}

        public virtual BindingSource UserControlBindingSource { get { return null; } }

        protected NorthwindNETEntities _context;
        internal virtual void SetBindingSource()
        {
            _context = Globals.CreateObjectContext() as NorthwindNETEntities;
            if (UserControlBindingSource != null)
            {
                UserControlBindingSource.DataSource = GetEntitySet(_context); 
            }
        }

        protected void todo()
        {
            informationMessage("TO DO!");
        }

        protected void informationMessage(string message)
        {
            MessageBox.Show(message, Northwind.NET.Settings.Globals.APPLICATION_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

    }


}
